<template>
  <el-dialog title="财务总监审批" :close-on-click-modal="false" :visible.sync="ishmangg" width="30%" @close="close">
    <el-form ref="ruleForm" :model="fData" :rules="rules" label-width="80px">
      <el-form-item label="审批意见">
        <el-radio-group v-model="fData.radio">
          <el-radio :label="1">同意</el-radio>
          <el-radio :label="2">不同意</el-radio>
          <el-radio :label="3">跳过</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备注" prop="txt">
        <el-input
          v-model="fData.txt"
          type="textarea"
          :autosize="{ minRows: 2, maxRows: 4}"
          placeholder="请输入内容"
        >
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="success" @click="outmanage">提交</el-button>
        <el-button size="small" type="danger" @click="close">关闭</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      ishmangg: true,
      fData: {
        date: '',
        txt: '',
        radio: 1
      },
      rules: {
        date: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ],         
        txt: [
          { required: true, message: '请输入备注', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
      }
    }
  },
  methods: {
    handlabel(radio) {
      console.log(radio)
    },
    openmagge() {
      this.ishmangg = true
    },
    outmanage() {
      // this.ishmangg = false
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    close() {
      if (this.ishmangg) {
        this.$confirm('你确定要离吗？')
          .then(_ => {
            this.ishmangg = false
            this.$refs.ruleForm.resetFields()
          })
          .catch(_ => {})
      }
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
